package interceptor;

import action.CharacterAction;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * @author dingyuanwei
 * @version 建立時間：Dec 24, 20101:30:57 PM
 * 類別說明:
 */
public class CharacterInterceptor extends AbstractInterceptor{

	@Override
	public String intercept(ActionInvocation ai) throws Exception {
		Object object= ai.getAction();
		if(object != null){
			if (object instanceof CharacterAction) {
				CharacterAction ca = (CharacterAction) object;
				String content = ca.getContent();
				if(content.contains("不")){
					content = content.replaceAll("不", "#");
					ca.setContent(content);
					
				}
				return ai.invoke();
			}else{
				return Action.LOGIN;
			}
		}
		return Action.LOGIN;
	}

}
